<?php
// 本文档自动生成，仅供测试运行
class ContentAction extends Action
{

	/**
	 * ------------------------------
	 * 预处理
	 * ------------------------------
	 */
	function _initialize(){
		if( !isset($_SESSION['adm_name']) or !isset($_SESSION['isAdmin']) ) $this->redirect('Index/login');
	}

	/**
	 * ------------------------------
	 * 权限判断
	 * ------------------------------
	 */
	function pan_quan_ajax($data){  //ajax判断
		$pan=in_array($data,$_SESSION['admin_quan']);
        if($pan){
			return true;
		}else{
			return false;
		}
	}
	function pan_quan($data){ //php跳转判断
		$pan=in_array($data,$_SESSION['admin_quan']);
        if(!$pan){
			$this->error('您权限不足');
		}
	}
	 
    /**
	 * ------------------------------
	 * 搜索微博
	 * ------------------------------
	 */
	function search(){
		 $name=$_REQUEST['name'];
		 $this->assign('name',$name);	 	
		import("@.ORG.Page");
		$count	= M('weibo')->where("content like '%$name%'")->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('weibo')->where("content like '%$name%'")->order('time desc,id desc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();

		
	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '搜索微博列表');
	
		$this->display('weibo');
	 }	

 
	/**
	 * ------------------------------
	 *  视频
	 * ------------------------------
	 */

	function videos(){
		$zhuboid=intval($_GET['zhuboid']);
	    $this->assign('zhuboid', $zhuboid);
		import("@.ORG.Page");
		$count	= M('videos')->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		if(empty($zhuboid)){
			$list = M('videos')->order('id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
		}else{
			$list = M('videos')->where("zhuboid=".$zhuboid."")->order('id desc')->limit($Page->firstRow.','.$Page->listRows)->select();
		}
		foreach($list as $k=>$v){
			$fenlei=M('videos_fenlei')->find($v['fid']);
			if(!empty($fenlei)){
				$list[$k]['fname']=$fenlei['name'];
			}else{
				$list[$k]['fname']="暂无";
			}
		}
	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '视频列表');
		$this->display();
	 }
	
	function editvideos(){
        $id = intval($_GET['id']);
		$zhuboid=intval($_GET['zhuboid']);
	    $this->assign('zhuboid', $zhuboid);
		if($id==''){
			$pan_admin=$this->pan_quan(2);//判断权限
			
			$this->assign('pagetitle', '添加视频');
		}else{
			$pan_admin=$this->pan_quan(4);//判断权限
			
			 $list = M('videos')->find($id);
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改视频');
		}
		$lang=M('pz_lang')->where("state=1")->order('xu asc,id asc')->select();
		foreach($lang as $k=>$v){
			$lang[$k]['menu_img_name']=$list["img_name".$v['id'].""];
			$lang[$k]['menu_img']=$list["img".$v['id'].""];
		}
	    $this->assign('lang_img_name', $lang);
	    $this->assign('lang_img', $lang);

		$fenlei=M('videos_fenlei')->where("state=1")->order('xu asc,id asc')->select();
	    $this->assign('fenlei', $fenlei);

		$this->display('videos_edit');
	}
   
   function dovideos(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		
		$_POST['uid']=$_SESSION['uid'];
		$zhuboid=$_POST['zhuboid'];
		if($_POST['id']){
			$_POST['stime']=time();
				if( M('videos')->save($_POST) ){
					$this->assign('jumpUrl', U('Content/videos',array(zhuboid=>$zhuboid)));
					$this->success('修改成功！');
				}else{
					$this->error('没有任何改动　或　修改失败！');
				}
		}else{
			$_POST['ctime']=time();
			$_POST['stime']=time();
		      if( M('videos')->add($_POST) ){
					$this->assign('jumpUrl', U('Content/videos',array(zhuboid=>$zhuboid)));
					$this->success('添加成功！');
			  }else{
					$this->error('添加失败！');
			  }
		}
	}
	/**
	 * ------------------------------
	 * 分类配置
	 * ------------------------------
	 */
	function videos_fenlei(){
	
		import("@.ORG.Page");
		$count	= M('videos_fenlei')->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('videos_fenlei')->order('xu asc,id asc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();
		foreach($list as $k=>$v){
			if($v['mid']==0){
				$list[$k]['mname']="顶级分类";
			}else{
				$mname=M('videos_fenlei')->find($v['pid']);
				$list[$k]['mname']=$mname['name'];
			}
			$list[$k]['lang_xus']=M('pz_lang')->where("state=1")->order('xu asc,id asc')->select();
			foreach($list[$k]['lang_xus'] as $kk=>$vv){
				$list[$k]['lang_xus'][$kk]['videos_fenlei_xu']=$v["xu".$vv['id'].""];
			}
			$webs=M('webs')->find($v['webid']);
			if(!empty($webs)){
				$list[$k]['wname']=$webs['name'];
			}else{
				$list[$k]['wname']="暂无";
			}
		}
		
		$lang=M('pz_lang')->where("state=1")->order('xu asc,id asc')->select();
	    $this->assign('lang_xu', $lang);

	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '分类配置列表');
	
		$this->display();
	 }
	
	function editvideos_fenlei(){
        $id = intval($_GET['id']);
		$topvideos_fenlei=M('videos_fenlei')->where("pid=0")->order('xu asc,id asc')->select();
	    $this->assign('topvideos_fenlei', $topvideos_fenlei);
		if($id==''){
		     $this->assign('pagetitle', '添加分类配置');
		}else{
			 $list = M('videos_fenlei')->find($id);
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改分类配置');
		}
		$lang=M('pz_lang')->where("state=1")->order('xu asc,id asc')->select();
		foreach($lang as $k=>$v){
			$lang[$k]['videos_fenlei_name']=$list["name".$v['id'].""];
			$lang[$k]['videos_fenlei_xu']=$list["xu".$v['id'].""];
		}
	    $this->assign('lang', $lang);
	    $this->assign('lang_xu', $lang);
		$webs=M('webs')->where("state=1")->order('id asc')->select();
	    $this->assign('webs', $webs);
		
		$this->display('videos_fenlei_edit');
	}
   
   function dovideos_fenlei(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		
		
		$_POST['state']=1;
		$_POST['uid']=$_SESSION['uid'];
		if($_POST['id']){
			$_POST['stime']=time();
				if( M('videos_fenlei')->save($_POST) ){
					$this->assign('jumpUrl', U('Content/videos_fenlei'));
					$this->success('修改成功！');
				}else{
					$this->error('没有任何改动　或　修改失败！');
				}
		}else{
			$_POST['ctime']=time();
			$_POST['stime']=time();
		      if( M('videos_fenlei')->add($_POST) ){
					$this->assign('jumpUrl', U('Content/videos_fenlei'));
					$this->success('添加成功！');
			  }else{
					$this->error('添加失败！');
			  }
		}
	}
	/**
	 * ------------------------------
	 *  图片
	 * ------------------------------
	 */

	function imgs(){
	
		import("@.ORG.Page");
		$count	= M('imgs')->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('imgs')->order('id desc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();
		foreach($list as $k=>$v){
			$fenlei=M('imgs_fenlei')->find($v['fid']);
			if(!empty($fenlei)){
				$list[$k]['fname']=$fenlei['name'];
			}else{
				$list[$k]['fname']="暂无";
			}
		}
	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '视频列表');
		$this->display();
	 }
	
	function editimgs(){
        $id = intval($_GET['id']);
		if($id==''){
			$pan_admin=$this->pan_quan(2);//判断权限
			
			$this->assign('pagetitle', '添加视频');
		}else{
			$pan_admin=$this->pan_quan(4);//判断权限
			
			 $list = M('imgs')->find($id);
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改视频');
		}
		$lang=M('pz_lang')->where("state=1")->order('xu asc,id asc')->select();
		foreach($lang as $k=>$v){
			$lang[$k]['menu_img_name']=$list["img_name".$v['id'].""];
			$lang[$k]['menu_img']=$list["img".$v['id'].""];
		}
	    $this->assign('lang_img_name', $lang);
	    $this->assign('lang_img', $lang);

		$fenlei=M('imgs_fenlei')->where("state=1")->order('xu asc,id asc')->select();
	    $this->assign('fenlei', $fenlei);

		$this->display('imgs_edit');
	}
   
   function doimgs(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		
		$_POST['uid']=$_SESSION['uid'];
		if($_POST['id']){
			$_POST['stime']=time();
				if( M('imgs')->save($_POST) ){
					$this->assign('jumpUrl', U('Content/imgs'));
					$this->success('修改成功！');
				}else{
					$this->error('没有任何改动　或　修改失败！');
				}
		}else{
			$_POST['ctime']=time();
			$_POST['stime']=time();
		      if( M('imgs')->add($_POST) ){
					$this->assign('jumpUrl', U('Content/imgs'));
					$this->success('添加成功！');
			  }else{
					$this->error('添加失败！');
			  }
		}
	}
	/**
	 * ------------------------------
	 * 图片 分类配置
	 * ------------------------------
	 */
	function imgs_fenlei(){
	
		import("@.ORG.Page");
		$count	= M('imgs_fenlei')->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('imgs_fenlei')->order('xu asc,id asc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();
		foreach($list as $k=>$v){
			if($v['mid']==0){
				$list[$k]['mname']="顶级分类";
			}else{
				$mname=M('imgs_fenlei')->find($v['pid']);
				$list[$k]['mname']=$mname['name'];
			}
			$list[$k]['lang_xus']=M('pz_lang')->where("state=1")->order('xu asc,id asc')->select();
			foreach($list[$k]['lang_xus'] as $kk=>$vv){
				$list[$k]['lang_xus'][$kk]['imgs_fenlei_xu']=$v["xu".$vv['id'].""];
			}
			$webs=M('webs')->find($v['webid']);
			if(!empty($webs)){
				$list[$k]['wname']=$webs['name'];
			}else{
				$list[$k]['wname']="暂无";
			}
		}
		
		$lang=M('pz_lang')->where("state=1")->order('xu asc,id asc')->select();
	    $this->assign('lang_xu', $lang);

	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '分类配置列表');
	
		$this->display();
	 }
	
	function editimgs_fenlei(){
        $id = intval($_GET['id']);
		$topimgs_fenlei=M('imgs_fenlei')->where("pid=0")->order('xu asc,id asc')->select();
	    $this->assign('topimgs_fenlei', $topimgs_fenlei);
		if($id==''){
		     $this->assign('pagetitle', '添加分类配置');
		}else{
			 $list = M('imgs_fenlei')->find($id);
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改分类配置');
		}
		$lang=M('pz_lang')->where("state=1")->order('xu asc,id asc')->select();
		foreach($lang as $k=>$v){
			$lang[$k]['imgs_fenlei_name']=$list["name".$v['id'].""];
			$lang[$k]['imgs_fenlei_xu']=$list["xu".$v['id'].""];
		}
	    $this->assign('lang', $lang);
	    $this->assign('lang_xu', $lang);
		$webs=M('webs')->where("state=1")->order('id asc')->select();
	    $this->assign('webs', $webs);
		
		$this->display('imgs_fenlei_edit');
	}
   
   function doimgs_fenlei(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		
		
		$_POST['state']=1;
		$_POST['uid']=$_SESSION['uid'];
		if($_POST['id']){
			$_POST['stime']=time();
				if( M('imgs_fenlei')->save($_POST) ){
					$this->assign('jumpUrl', U('Content/imgs_fenlei'));
					$this->success('修改成功！');
				}else{
					$this->error('没有任何改动　或　修改失败！');
				}
		}else{
			$_POST['ctime']=time();
			$_POST['stime']=time();
		      if( M('imgs_fenlei')->add($_POST) ){
					$this->assign('jumpUrl', U('Content/imgs_fenlei'));
					$this->success('添加成功！');
			  }else{
					$this->error('添加失败！');
			  }
		}
	}
	
	/**
	 * ------------------------------
	 * 单页_文章管理
	 * ------------------------------
	 */
	function page_art(){
	
		import("@.ORG.Page");
		$count	= M('page_art')->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('page_art')->order('xu asc,ctime desc,id desc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();
		foreach($list as $k=>$v){
			$user=M("admin")->find($v['uid']);
			$list[$k]['username']=$user['adm_name'];
			if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
				$list[$k]['name']=stripslashes($v['name']); 
			}
		}

	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '单页_文章列表');
	
		$this->display();
	 }
	
	function editpage_art(){
        $id = intval($_GET['id']);
		if($id==''){
			$this->assign('pagetitle', '添加文章');
		}else{
			$list = M('page_art')->find($id);
			foreach($list as $k=>$v){
				if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
					$list[$k]=stripslashes($v); 
				}
			}
			$this->assign($list);
			$this->assign('type', 'edit');
			$this->assign('pagetitle', '修改文章');
		}
		$lang=M('pz_lang')->where("state=1")->order('xu asc,id asc')->select();
		foreach($lang as $k=>$v){
			$lang[$k]['menu_name']=$list["name".$v['id'].""];
			$lang[$k]['menu_content']=$list["content".$v['id'].""];
		}
	    $this->assign('lang_name', $lang);
	    $this->assign('lang_content', $lang);
		$this->display('page_art_edit');
	}
   
   function dopage_art(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		$_POST['state']=1;
		
		if($_POST['id']){
			$pan_admin=$this->pan_quan(2);//判断权限
			$_POST['stime']=time();
			if( M('page_art')->save($_POST) ){
				$this->assign('jumpUrl', U('Content/page_art'));
				$this->success('修改成功！');
			}else{
				$this->error('没有任何改动　或　修改失败！');
			}
		}else{
			$pan_admin=$this->pan_quan(4);//判断权限
			$_POST['uid']=$_SESSION['uid'];
			$_POST['xu']=9999;
			$_POST['ctime']=time();
			$_POST['stime']=time();
			if( M('page_art')->add($_POST) ){
				$this->assign('jumpUrl', U('Content/page_art'));
				$this->success('添加成功！');
			}else{
				$this->error('添加失败！');
			}
		}
	}
	
//	function delpage_art(){
//	    $ids = $_POST['ids'];
//		$del = M('page_art')->where("id IN ($ids)")->setField('state','0');;
//        echo $del?'1':'0';
//	}	
	/**
	 * ------------------------------
	 * 文章管理
	 * ------------------------------
	 */
	function article(){
		
		$state_id=$_GET['st'];
		if($state_id===NULL){
			$map=" state!=3 ";
		}else{
			if($state_id>=0){
				$map=" state=".$state_id." ";
			}
		}
		
		$menu_id=$_GET['mid'];
		if($menu_id===NULL){
			//$map.=" state!=3 ";
		}else{
			if($menu_id>0){
				$ss_menuid=",".$menu_id.",";
				$map.=" and menuid like '%".$ss_menuid."%' ";
			}else{
				$map.=" and menuid = ',,' ";
			}
		}
		
		$bianji_id=$_GET['bjid'];
		if($bianji_id===NULL){
			//$map.=" state!=3 ";
		}else{
			$uids=M('admin')->where("groupid=".$bianji_id."")->select();
			foreach($uids as $k=>$v){
				$uids_str.=$v['id'].",";
			}
			$uids_str=rtrim($uids_str,",");
			$map.=" and uid IN (".$uids_str.") ";
		}
		
		$menus = M('pz_menu')->where("mid=0")->order('xu asc,id desc')->select();
	    $this->assign('menus', $menus);
		$bianjis = M('admin_group')->where("id!=6 and id!=7 and id!=8")->order('xu asc,id desc')->select();
	    $this->assign('bianjis', $bianjis);
		
	    $this->assign('state_id', $state_id);
	    $this->assign('menu_id', $menu_id);
	    $this->assign('bianji_id', $bianji_id);
		
		import("@.ORG.Page");
		$count	= M('article')->where($map)->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('article')->where($map)->order('stime desc,id desc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();
		foreach($list as $k=>$v){
			$user=M("admin")->find($v['uid']);
			$list[$k]['username']=$user['adm_name'];
			if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
				$list[$k]['name']=stripslashes($v['name']); 
			}
		}

	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '文章列表');
	
		$this->display();
	 }
	
	function search_article(){
		
		$ss_key=t(h($_POST['ss_key']));
		
		$list = M('article')->where("id='$ss_key' or name like '%$ss_key%' or name1 like '%$ss_key%' or name2 like '%$ss_key%' ")->order('stime desc,id desc')->select();
		foreach($list as $k=>$v){
			$user=M("admin")->find($v['uid']);
			$list[$k]['username']=$user['adm_name'];
			if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
				$list[$k]['name']=stripslashes($v['name']); 
			}
		}

	    $this->assign('list', $list);
		$this->assign('pagetitle', '文章列表');
	
		$this->display("article");
	 }
	
	function editarticle(){
        $id = intval($_GET['id']);
		$shop = M('shop')->order('ctime desc,id desc')->select();
	    $this->assign('shop', $shop);
		$areas = M('pz_area')->order('ctime desc,id desc')->select();
	    $this->assign('areas', $areas);
		$menus = M('pz_menu')->where("mid=0")->order('xu asc,id desc')->select();
	    $this->assign('menus', $menus);
	    $this->assign('menusr', $menus);
	    $this->assign('menusl', $menus);
		if($id==''){
			$this->assign('pagetitle', '添加文章');
		}else{
			$list = M('article')->find($id);
			foreach($list as $k=>$v){
				if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
					$list[$k]=stripslashes($v); 
				}
			}
			$this->assign($list);
			$list['shopid']=trim($list['shopid'],",");
			$sshopid=explode(",",$list['shopid']);
			foreach($sshopid as $kk=>$vv){
				$sshop[$kk]=M('shop')->find($vv);
			}
			$this->assign('sshop',$sshop);
			$this->assign('type', 'edit');
			$this->assign('pagetitle', '修改文章');
		}
		$lang=M('pz_lang')->where("state=1")->order('xu asc,id asc')->select();
		foreach($lang as $k=>$v){
			$lang[$k]['menu_name']=$list["name".$v['id'].""];
			$lang[$k]['menu_namesm']=$list["namesm".$v['id'].""];
			$lang[$k]['menu_content']=$list["content".$v['id'].""];
			$lang[$k]['menu_areainf']=$list["areainf".$v['id'].""];
			$lang[$k]['menu_remark']=$list["remark".$v['id'].""];
			$lang[$k]['menu_qa']=$list["qa".$v['id'].""];
			$lang[$k]['menu_service']=$list["service".$v['id'].""];
			$lang[$k]['menu_service_out']=$list["service_out".$v['id'].""];
			$lang[$k]['menu_service_pack']=$list["service_pack".$v['id'].""];
			$lang[$k]['menu_zhutu']=$list["zhutu".$v['id'].""];
			$lang[$k]['menu_zhutuly']=$list["zhutuly".$v['id'].""];
		}
	    $this->assign('lang_name', $lang);
	    $this->assign('lang_namesm', $lang);
	    $this->assign('lang_content', $lang);
	    $this->assign('lang_areainf', $lang);
	    $this->assign('lang_remark', $lang);
	    $this->assign('lang_qa', $lang);
	    $this->assign('lang_service', $lang);
	    $this->assign('lang_service_out', $lang);
	    $this->assign('lang_service_pack', $lang);
	    $this->assign('lang_zhutu', $lang);
	    $this->assign('lang_zhutuly', $lang);
		$this->display('article_edit');
	}
   
   function doarticle(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		
		$_POST['menuid']=",".$_POST['menuid'].",";
		$_POST['area_id']=",".$_POST['area_id'].",";
		$_POST['menurid']=",".$_POST['menurid'].",";
		$_POST['menulid']=",".$_POST['menulid'].",";
		$_POST['shopid']=rtrim($_POST['shopid'],",");
		$_POST['shopid']=",".$_POST['shopid'].",";
		if($_POST['id']){
			$pan_admin=$this->pan_quan(2);//判断权限
			$_POST['stime']=time();
			if( M('article')->save($_POST) ){
				$this->assign('jumpUrl', U('Content/article'));
				$this->success('修改成功！');
			}else{
				$this->error('没有任何改动　或　修改失败！');
			}
		}else{
			$pan_admin=$this->pan_quan(4);//判断权限
			$_POST['uid']=$_SESSION['uid'];
			$_POST['ctime']=time();
			$_POST['stime']=time();
			if( M('article')->add($_POST) ){
				$this->assign('jumpUrl', U('Content/article'));
				$this->success('添加成功！');
			}else{
				$this->error('添加失败！');
			}
		}
	}
	/**
	 * ------------------------------
	 * 测评管理
	 * ------------------------------
	 */
	function ti_fenlei(){
		
		
		import("@.ORG.Page");
		$count	= M('ti_fenlei')->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('ti_fenlei')->order('ctime desc,id desc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();
		foreach($list as $k=>$v){
			$user=M("admin")->find($v['uid']);
			$list[$k]['username']=$user['adm_name'];
			if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
				$list[$k]['name']=stripslashes($v['name']); 
			}
		}

	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '测评试卷');
	
		$this->display();
	 }
	
	
	function editti_fenlei(){
        $id = intval($_GET['id']);
		if($id==''){
			$this->assign('pagetitle', '添加测评试卷');
		}else{
			$list = M('ti_fenlei')->find($id);
			foreach($list as $k=>$v){
				if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
					$list[$k]=stripslashes($v); 
				}
			}
			$this->assign($list);
			$this->assign('type', 'edit');
			$this->assign('pagetitle', '修改测评试卷');
		}
		$this->display('ti_fenlei_edit');
	}
   
   function doti_fenlei(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		
		if($_POST['id']){
			$_POST['stime']=time();
			if( M('ti_fenlei')->save($_POST) ){
				$this->assign('jumpUrl', U('Content/ti_fenlei'));
				$this->success('修改成功！');
			}else{
				$this->error('没有任何改动　或　修改失败！');
			}
		}else{
			$_POST['uid']=$_SESSION['uid'];
			$_POST['ctime']=time();
			$_POST['stime']=time();
			$_POST['state']=1;
			if( M('ti_fenlei')->add($_POST) ){
				$this->assign('jumpUrl', U('Content/ti_fenlei'));
				$this->success('添加成功！');
			}else{
				$this->error('添加失败！');
			}
		}
	}
	function ti_xuan(){
		
		$tid=$_GET['tid'];
		import("@.ORG.Page");
		$count	= M('ti_xuan')->where("tid=".$tid."")->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('ti_xuan')->where("tid=".$tid."")->order('ctime desc,id desc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();
		foreach($list as $k=>$v){
			$user=M("admin")->find($v['uid']);
			$list[$k]['username']=$user['adm_name'];
			if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
				$list[$k]['name']=stripslashes($v['name']); 
			}
		}

	    $this->assign('tid', $tid);
	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '测评试题选项');
	
		$this->display();
	 }
	
	
	function editti_xuan(){
        $id = intval($_GET['id']);
		if($id==''){
			$tid = intval($_GET['tid']);
			$tiname=M("ti")->where("id=".$tid."")->find();
			$this->assign('tiname', $tiname);
			$this->assign('pagetitle', '添加测评试题选项');
		}else{
			$list = M('ti_xuan')->find($id);
			$tid = intval($list['tid']);
			$tiname=M("ti")->where("id=".$tid."")->find();
			$this->assign('tiname', $tiname);
			foreach($list as $k=>$v){
				if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
					$list[$k]=stripslashes($v); 
				}
			}
			$this->assign($list);
			$this->assign('type', 'edit');
			$this->assign('pagetitle', '修改测评试题选项');
		}
	    $this->assign('tid', $tid);
		$this->display('ti_xuan_edit');
	}
   
   function doti_xuan(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		$tid=$_POST['tid'];
		if($_POST['id']){
			$_POST['stime']=time();
			if( M('ti_xuan')->save($_POST) ){
				$this->assign('jumpUrl',"./admin.php?a=ti_xuan&m=content&tid=".$tid."");
				$this->success('修改成功！');
			}else{
				$this->error('没有任何改动　或　修改失败！');
			}
		}else{
			$_POST['uid']=$_SESSION['uid'];
			$_POST['ctime']=time();
			$_POST['stime']=time();
			$_POST['state']=1;
			if( M('ti_xuan')->add($_POST) ){
				$this->assign('jumpUrl',"./admin.php?a=ti_xuan&m=content&tid=".$tid."");
				$this->success('添加成功！');
			}else{
				$this->error('添加失败！');
			}
		}
	}
	function ti(){
		
		$fid=$_GET['fid'];
		import("@.ORG.Page");
		$count	= M('ti')->where("fid=".$fid."")->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('ti')->where("fid=".$fid."")->order('ctime desc,id desc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();
		foreach($list as $k=>$v){
			$user=M("admin")->find($v['uid']);
			$list[$k]['username']=$user['adm_name'];
			if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
				$list[$k]['name']=stripslashes($v['name']); 
			}
		}

	    $this->assign('fid', $fid);
	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '测评试题');
	
		$this->display();
	 }
	
	
	function editti(){
        $id = intval($_GET['id']);
		if($id<=0){
			$fid = intval($_GET['fid']);
			$fenlei=M("ti_fenlei")->where("id=".$fid."")->find();
			$this->assign('fenlei', $fenlei);
		}else{
			$fid = intval($_GET['fid']);
		
		}
		if($id==''){
			$this->assign('pagetitle', '添加测评试题');
			$fid = intval($_GET['fid']);
			$fenlei=M("ti_fenlei")->where("id=".$fid."")->find();
			$this->assign('fenlei', $fenlei);
		}else{
			$list = M('ti')->find($id);
			foreach($list as $k=>$v){
				if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
					$list[$k]=stripslashes($v); 
				}
			}
			$fid = intval($list['fid']);
			$fenlei=M("ti_fenlei")->where("id=".$fid."")->find();
			$this->assign('fenlei', $fenlei);
			$this->assign($list);
			$this->assign('type', 'edit');
			$this->assign('pagetitle', '修改测评试题');
		}
		$this->assign('fid', $fid);
		$this->display('ti_edit');
	}
   
   function doti(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		$fid=$_POST['fid'];
		if($_POST['id']){
			$_POST['stime']=time();
			if( M('ti')->save($_POST) ){
				$this->assign('jumpUrl', "./admin.php?a=ti&m=content&fid=".$fid."");
				$this->success('修改成功！');
			}else{
				$this->error('没有任何改动　或　修改失败！');
			}
		}else{
			$_POST['uid']=$_SESSION['uid'];
			$_POST['ctime']=time();
			$_POST['stime']=time();
			$_POST['state']=1;
			if( M('ti')->add($_POST) ){
				$this->assign('jumpUrl', "./admin.php?a=ti&m=content&fid=".$fid."");
				$this->success('添加成功！');
			}else{
				$this->error('添加失败！');
			}
		}
	}
	function ti_jieguo(){
		
		$fid=$_GET['fid'];
		import("@.ORG.Page");
		$count	= M('ti_jieguo')->where("fid=".$fid."")->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('ti_jieguo')->where("fid=".$fid."")->order('ctime desc,id desc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();
		foreach($list as $k=>$v){
			$user=M("admin")->find($v['uid']);
			$list[$k]['username']=$user['adm_name'];
			if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
				$list[$k]['name']=stripslashes($v['name']); 
			}
		}

	    $this->assign('fid', $fid);
	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '测评答案');
	
		$this->display();
	 }
	
	
	function editti_jieguo(){
        $id = intval($_GET['id']);
		if($id==''){
			$this->assign('pagetitle', '添加测评答案');
			$fid = intval($_GET['fid']);
			$fenlei=M("ti_fenlei")->where("id=".$fid."")->find();
			$this->assign('fenlei', $fenlei);
		}else{
			$list = M('ti_jieguo')->find($id);
			foreach($list as $k=>$v){
				if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
					$list[$k]=stripslashes($v); 
				}
			}
			$fid = intval($list['fid']);
			$fenlei=M("ti_fenlei")->where("id=".$fid."")->find();
			$this->assign('fenlei', $fenlei);
			$this->assign($list);
			$this->assign('type', 'edit');
			$this->assign('pagetitle', '修改测评答案');
		}
		$this->assign('fid', $fid);
		$this->display('ti_jieguo_edit');
	}
   
   function doti_jieguo(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		$fid=$_POST['fid'];
		if($_POST['id']){
			$_POST['stime']=time();
			if( M('ti_jieguo')->save($_POST) ){
				$this->assign('jumpUrl', "./admin.php?a=ti_jieguo&m=content&fid=".$fid."");
				$this->success('修改成功！');
			}else{
				$this->error('没有任何改动　或　修改失败！');
			}
		}else{
			$_POST['uid']=$_SESSION['uid'];
			$_POST['ctime']=time();
			$_POST['stime']=time();
			$_POST['state']=1;
			if( M('ti_jieguo')->add($_POST) ){
				$this->assign('jumpUrl', "./admin.php?a=ti_jieguo&m=content&fid=".$fid."");
				$this->success('添加成功！');
			}else{
				$this->error('添加失败！');
			}
		}
	}
	function ti_record(){
		
		$fid=$_GET['fid'];
		import("@.ORG.Page");
		$count	= M('ti_record')->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('ti_record')->order('ctime desc,id desc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();
		foreach($list as $k=>$v){
			$user=M("user")->find($v['uid']);
			$list[$k]['username']=$user['nicheng'];
			if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
				$list[$k]['name']=stripslashes($v['name']); 
			}
		}

	    $this->assign('fid', $fid);
	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '测评结果');
	
		$this->display();
	 }
	
	
	function editti_record(){
        $id = intval($_GET['id']);
		if($id==''){
			$this->assign('pagetitle', '添加测评结果');
		}else{
			$list = M('ti_record')->find($id);
			foreach($list as $k=>$v){
				if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
					$list[$k]=stripslashes($v); 
				}
			}
			$this->assign($list);
			$this->assign('type', 'edit');
			$this->assign('pagetitle', '修改测评结果');
		}
		$this->assign('fid', $fid);
		$this->display('ti_record_edit');
	}
   
   function doti_record(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		$fid=$_POST['fid'];
		if($_POST['id']){
			$_POST['stime']=time();
			if( M('ti_record')->save($_POST) ){
				$this->assign('jumpUrl', "./admin.php?a=ti_record&m=content");
				$this->success('修改成功！');
			}else{
				$this->error('没有任何改动　或　修改失败！');
			}
		}else{
			$_POST['uid']=$_SESSION['uid'];
			$_POST['ctime']=time();
			$_POST['stime']=time();
			$_POST['state']=1;
			if( M('ti_record')->add($_POST) ){
				$this->assign('jumpUrl', "./admin.php?a=ti_record&m=content");
				$this->success('添加成功！');
			}else{
				$this->error('添加失败！');
			}
		}
	}
	/**
	 * ------------------------------
	 * 文章管理
	 * ------------------------------
	 */
	function news(){
		
		$state_id=$_GET['st'];
		if($state_id===NULL){
			$map=" state!=3 ";
		}else{
			if($state_id>=0){
				$map=" state=".$state_id." ";
			}
		}
		
		
		import("@.ORG.Page");
		$count	= M('news')->where($map)->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('news')->where($map)->order('stime desc,id desc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();
		foreach($list as $k=>$v){
			$user=M("admin")->find($v['uid']);
			$list[$k]['username']=$user['adm_name'];
			if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
				$list[$k]['name']=stripslashes($v['name']); 
			}
		}

	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '文章列表');
	
		$this->display();
	 }
	
	function search_news(){
		
		$ss_key=t(h($_POST['ss_key']));
		
		$list = M('news')->where("id='$ss_key' or name like '%$ss_key%'")->order('stime desc,id desc')->select();
		foreach($list as $k=>$v){
			$user=M("admin")->find($v['uid']);
			$list[$k]['username']=$user['adm_name'];
			if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
				$list[$k]['name']=stripslashes($v['name']); 
			}
		}

	    $this->assign('list', $list);
		$this->assign('pagetitle', '文章列表');
	
		$this->display("news");
	 }
	
	function editnews(){
        $id = intval($_GET['id']);
		if($id==''){
			$this->assign('pagetitle', '添加文章');
		}else{
			$list = M('news')->find($id);
			foreach($list as $k=>$v){
				if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
					$list[$k]=stripslashes($v); 
				}
			}
			$this->assign($list);
			$this->assign('type', 'edit');
			$this->assign('pagetitle', '修改文章');
		}
		$lang=M('pz_lang')->where("state=1")->order('xu asc,id asc')->select();
		foreach($lang as $k=>$v){
			$lang[$k]['menu_name']=$list["name".$v['id'].""];
			$lang[$k]['menu_namesm']=$list["namesm".$v['id'].""];
			$lang[$k]['menu_content']=$list["content".$v['id'].""];
			$lang[$k]['menu_zhutu']=$list["zhutu".$v['id'].""];
		}
	    $this->assign('lang_name', $lang);
	    $this->assign('lang_namesm', $lang);
	    $this->assign('lang_content', $lang);
	    $this->assign('lang_zhutu', $lang);
		$this->display('news_edit');
	}
   
   function donews(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		
		if($_POST['id']){
			$pan_admin=$this->pan_quan(2);//判断权限
			$_POST['stime']=time();
			if( M('news')->save($_POST) ){
				$this->assign('jumpUrl', U('Content/news'));
				$this->success('修改成功！');
			}else{
				$this->error('没有任何改动　或　修改失败！');
			}
		}else{
			$pan_admin=$this->pan_quan(4);//判断权限
			$_POST['uid']=$_SESSION['uid'];
			$_POST['ctime']=time();
			$_POST['stime']=time();
			if( M('news')->add($_POST) ){
				$this->assign('jumpUrl', U('Content/news'));
				$this->success('添加成功！');
			}else{
				$this->error('添加失败！');
			}
		}
	}
	
//	function delarticle(){
//	    $ids = $_POST['ids'];
//		$del = M('article')->where("id IN ($ids)")->setField('state','3');
//        echo $del?'1':'0';
//	}	
  
	/**
	 * ------------------------------
	 * 自动保存 文章
	 * ------------------------------
	 */
	function auto_save_article(){
	    $id = $_POST['id'];
	    $con = $_POST['con'];
	    $obj = $_POST['obj'];
		$save['id']=$id;
		$save[$obj]=$con;
		//$save['uid']=$_SESSION['uid'];

		if($id){
			$save['stime']=time();
			$cc=M('article')->save($save);
		}else{
			$save['ctime']=time();
			$save['uid']=$_SESSION['uid'];
			$save['stime']=time();
			$cc=M('article')->add($save);
		}
        echo $cc?$cc:'0';
	}	
	/**
	 * ------------------------------
	 * 自动保存 文章-相册
	 * ------------------------------
	 */
	function auto_save_art_photo_files(){
	    $id = $_POST['id'];
	    $aid = $_POST['aid'];
	    $con = $_POST['con'];
	    $obj = $_POST['obj'];
		$suid = $_POST['suid'];
		$save['id']=$id;
		$save['aid']=$aid;
		$save['suid']=$suid;
		$save[$obj]=$con;
		$save['state']=1;
		//$save['uid']=$_SESSION['uid'];
		
		if($id){
			$save['stime']=time();
			$cc=M('article_photo_files')->save($save);
		}else{
			$save['uid']=$_SESSION['uid'];
			$save['ctime']=time();
			$save['stime']=time();
			$cc=M('article_photo_files')->add($save);
		}
        echo $cc?$cc:'0';
	}	
	/**
	 * ------------------------------
	 * 自动保存 商家-相册
	 * ------------------------------
	 */
	function auto_save_shop_photo_files(){
	    $id = $_POST['id'];
	    $aid = $_POST['aid'];
	    $con = $_POST['con'];
	    $obj = $_POST['obj'];
		$save['id']=$id;
		$save['aid']=$aid;
		$save[$obj]=$con;
		$save['state']=1;
		//$save['uid']=$_SESSION['uid'];
		
		if($id){
			$save['stime']=time();
			$cc=M('shop_photo_files')->save($save);
		}else{
			$save['uid']=$_SESSION['uid'];
			$save['ctime']=time();
			$save['stime']=time();
			$cc=M('shop_photo_files')->add($save);
		}
        echo $cc?$cc:'0';
	}	
	
	/**
	 * ------------------------------
	 * 文章-视频 管理
	 * ------------------------------
	 */
	function art_video(){
        $aid = intval($_GET['aid']);
		$this->assign('aid',$aid);
		$list = M('article_video')->where("aid=".$aid."")->order("xu asc,id desc")->select();
		foreach($list as $k=>$v){
			$user=M("admin")->find($v['uid']);
			$list[$k]['username']=$user['adm_name'];
			if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
				$list[$k]['name']=stripslashes($v['name']); 
			}
		}
		$this->assign('list',$list);
		$this->assign('pagetitle', '视频');
		$this->display();
	}

	function editart_video(){
        $id = intval($_GET['id']);
        $aid = intval($_GET['aid']);
		$this->assign('aid',$aid);
		if(!$aid){
			$this->assign('jumpUrl', U('Content/article'));
			$this->error('数据错误！');
		}
		if($id==''){
			$list_num=M('article_video')->where("aid=".$aid."")->count();
			if($list_num>=10){
				$this->assign('jumpUrl', U('Content/art_video',array(aid=>$aid)));
				$this->error('最多只能添加10个视频！');
			}
		     $this->assign('pagetitle', '添加视频');
		}else{
			 $list = M('article_video')->find($id);
				foreach($list as $k=>$v){
					if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
						$list[$k]=stripslashes($v); 
					} 
				}
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改视频');
		}
		
		$lang=M('pz_lang')->where("state=1")->order('xu asc,id asc')->select();
		foreach($lang as $k=>$v){
			$lang[$k]['menu_name']=$list["name".$v['id'].""];
			$lang[$k]['menu_url']=$list["url".$v['id'].""];
			$lang[$k]['menu_urlly']=$list["urlly".$v['id'].""];
			$lang[$k]['menu_intro']=$list["intro".$v['id'].""];
		}
	    $this->assign('lang_name', $lang);
	    $this->assign('lang_url', $lang);
	    $this->assign('lang_urlly', $lang);
	    $this->assign('lang_intro', $lang);

		$this->display('art_video_edit');
	}
   function doart_video(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
        $aid = intval($_POST['aid']);
		$this->assign('aid',$aid);
		if(!$aid){
			$this->assign('jumpUrl', U('Content/article'));
			$this->error('数据错误！');
		}
		$_POST['aid']=$aid;
		$_POST['state']=1;
		
		if($_POST['id']){
			$_POST['stime']=time();
			if( M('article_video')->save($_POST) ){
				$this->assign('jumpUrl', U('Content/art_video',array(aid=>$aid)));
				$this->success('修改成功！');
			}else{
				$this->error('没有任何改动　或　修改失败！');
			}
		}else{
			$_POST['uid']=$_SESSION['uid'];
			$_POST['ctime']=time();
			$_POST['stime']=time();
			if( M('article_video')->add($_POST) ){
				$this->assign('jumpUrl', U('Content/art_video',array(aid=>$aid)));
				$this->success('添加成功！');
			}else{
				$this->error('添加失败！');
			}
		}
	}
	
//	function delart_video(){
//	    $ids = $_POST['ids'];
//		$del = M('article_video')->where("id IN ($ids)")->setField('state','3');
//        echo $del?'1':'0';
//	}	
//
//	function huiart_video(){
//	    $ids = $_POST['ids'];
//		$hui = M('article_video')->where("id IN ($ids)")->setField('state','1');
//        echo $hui?'1':'0';
//	}	

	/**
	 * ------------------------------
	 * 文章-相片集 管理
	 * ------------------------------
	 */
	function art_photo_files(){
        $aid = intval($_GET['aid']);
		$this->assign('aid',$aid);
        $suid = intval($_GET['suid']);
		$this->assign('suid',$suid);
		if(empty($suid)){
			$list = M('article_photo_files')->where("aid=".$aid."")->order("xu asc,id desc")->select();
		}else{
			$list = M('article_photo_files')->where("suid=".$suid."")->order("xu asc,id desc")->select();
		}
		foreach($list as $k=>$v){
			$user=M("admin")->find($v['uid']);
			$list[$k]['username']=$user['adm_name'];
			if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
				$list[$k]['name']=stripslashes($v['name']); 
			}
		}
		$this->assign('list',$list);
		$this->assign('pagetitle', '相册');
		$this->display();
	}

	function editart_photo_files(){
        $id = intval($_GET['id']);
        $aid = intval($_GET['aid']);
		$this->assign('aid',$aid);
        $suid = intval($_GET['suid']);
		$this->assign('suid',$suid);
//		if(!$aid){
//			$this->assign('jumpUrl', U('Content/article'));
//			$this->error('数据错误！');
//		}
		if($id==''){
//			$list_num=M('article_photo_files')->where("aid=".$aid."")->count();
//			if($list_num>=20){
//				$this->assign('jumpUrl', U('Content/art_photo_files',array(aid=>$aid)));
//				$this->error('最多只能添加20个相册！');
//			}
		     $this->assign('pagetitle', '添加相册');
		}else{
			 $list = M('article_photo_files')->find($id);
				foreach($list as $k=>$v){
					if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
						$list[$k]=stripslashes($v); 
					} 
				}
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改相册');
		}
		
		$lang=M('pz_lang')->where("state=1")->order('xu asc,id asc')->select();
		foreach($lang as $k=>$v){
			$lang[$k]['menu_name']=$list["name".$v['id'].""];
			$lang[$k]['menu_url']=$list["url".$v['id'].""];
			$lang[$k]['menu_urlly']=$list["urlly".$v['id'].""];
			$lang[$k]['menu_intro']=$list["intro".$v['id'].""];
		}
	    $this->assign('lang_name', $lang);
	    $this->assign('lang_url', $lang);
	    $this->assign('lang_urlly', $lang);
	    $this->assign('lang_intro', $lang);

		$this->display('art_photo_files_edit');
	}
   function doart_photo_files(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
        $aid = intval($_POST['aid']);
		$this->assign('aid',$aid);
        $suid = intval($_POST['suid']);
		$this->assign('suid',$suid);
//		if(!$aid && !$suid){
//			$this->assign('jumpUrl', U('Content/article'));
//			$this->error('数据错误！');
//		}
		$_POST['aid']=$aid;
		$_POST['suid']=$suid;
		$_POST['state']=1;
		
		if($_POST['id']){
			$_POST['stime']=time();
			if( M('article_photo_files')->save($_POST) ){
				$this->assign('jumpUrl', U('Content/art_photo_files',array(aid=>$aid,suid=>$suid)));
				$this->success('修改成功！');
			}else{
				$this->error('没有任何改动　或　修改失败！');
			}
		}else{
			$_POST['uid']=$_SESSION['uid'];
			$_POST['ctime']=time();
			$_POST['stime']=time();
			if( M('article_photo_files')->add($_POST) ){
				$this->assign('jumpUrl', U('Content/art_photo_files',array(aid=>$aid,suid=>$suid)));
				$this->success('添加成功！');
			}else{
				$this->error('添加失败！');
			}
		}
	}
	
//	function delart_photo_files(){
//	    $ids = $_POST['ids'];
//		$del = M('article_photo_files')->where("id IN ($ids)")->setField('state','3');
//        echo $del?'1':'0';
//	}	
//
//	function huiart_photo_files(){
//	    $ids = $_POST['ids'];
//		$del = M('article_photo_files')->where("id IN ($ids)")->setField('state','1');
//        echo $del?'1':'0';
//	}	

	/**
	 * ------------------------------
	 * 文章-相片管理
	 * ------------------------------
	 */
	function art_photo(){
        $fid = intval($_GET['fid']);
		$this->assign('fid',$fid);
		$photo_files=M('article_photo_files')->find($fid);
		$aid=$photo_files['aid'];
		$this->assign('aid',$aid);
		$suid=$photo_files['suid'];
		$this->assign('suid',$suid);
		$list = M('article_photo')->where("fid=".$fid."")->order("xu asc,id desc")->select();
		foreach($list as $k=>$v){
			$user=M("admin")->find($v['uid']);
			$list[$k]['username']=$user['adm_name'];
			if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
				$list[$k]['name']=stripslashes($v['name']); 
			}
		}
		$this->assign('list',$list);
		$this->assign('pagetitle', '相片');
		$this->display();
	}

	function editart_photo(){
        $id = intval($_GET['id']);
        $fid = intval($_GET['fid']);
		$this->assign('fid',$fid);
        $suid = intval($_GET['suid']);
		$this->assign('suid',$suid);
//		if(!$fid){
//			$this->assign('jumpUrl', U('Content/article'));
//			$this->error('数据错误！');
//		}
		if($id==''){
//			$list_num=M('article_photo')->where("fid=".$fid."")->count();
//			if($list_num>=20){
//				$this->assign('jumpUrl', U('Content/art_photo',array(fid=>$fid)));
//				$this->error('最多只能添加20张相片！');
//			}
		     $this->assign('pagetitle', '添加相片');
		}else{
			 $list = M('article_photo')->find($id);
				foreach($list as $k=>$v){
					if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
						$list[$k]=stripslashes($v); 
					} 
				}
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改相片');
		}
		
		$lang=M('pz_lang')->where("state=1")->order('xu asc,id asc')->select();
		foreach($lang as $k=>$v){
			$lang[$k]['menu_name']=$list["name".$v['id'].""];
			$lang[$k]['menu_url']=$list["url".$v['id'].""];
			$lang[$k]['menu_urlly']=$list["urlly".$v['id'].""];
		}
	    $this->assign('lang_name', $lang);
	    $this->assign('lang_url', $lang);
	    $this->assign('lang_urlly', $lang);

		$this->display('art_photo_edit');
	}
   function doart_photo(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
        $fid = intval($_POST['fid']);
		$this->assign('fid',$fid);
        $suid = intval($_POST['suid']);
		$this->assign('suid',$suid);
//		if(!$fid){
//			$this->assign('jumpUrl', U('Content/article'));
//			$this->error('数据错误！');
//		}
		$_POST['fid']=$fid;
		$_POST['suid']=$suid;
		$_POST['state']=1;
		
		if($_POST['id']){
			$_POST['stime']=time();
			if( M('article_photo')->save($_POST) ){
				$this->assign('jumpUrl', U('Content/art_photo',array(fid=>$fid,suid=>$suid)));
				$this->success('修改成功！');
			}else{
				$this->error('没有任何改动　或　修改失败！');
			}
		}else{
			$_POST['uid']=$_SESSION['uid'];
			$_POST['ctime']=time();
			$_POST['stime']=time();
			if( M('article_photo')->add($_POST) ){
				$this->assign('jumpUrl', U('Content/art_photo',array(fid=>$fid,suid=>$suid)));
				$this->success('添加成功！');
			}else{
				$this->error('添加失败！');
			}
		}
	}
	
//	function delart_photo(){
//	    $ids = $_POST['ids'];
//		$del = M('article_photo')->where("id IN ($ids)")->setField('state','3');
//        echo $del?'1':'0';
//	}	
//
//	function huiart_photo(){
//	    $ids = $_POST['ids'];
//		$del = M('article_photo')->where("id IN ($ids)")->setField('state','1');
//        echo $del?'1':'0';
//	}	

	/**
	 * ------------------------------
	 * 商家管理
	 * ------------------------------
	 */
	function shop(){
		
		$state_id=$_GET['st'];
		if($state_id===NULL){
			$map="";
		}else{
			if($state_id>=0){
				$map="state=".$state_id."";
			}
		}
			
		import("@.ORG.Page");
		$count	= M('shop')->where($map)->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('shop')->where($map)->order('ctime desc,id desc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();
		foreach($list as $k=>$v){
			$user=M("admin")->find($v['uid']);
			$list[$k]['username']=$user['adm_name'];
			if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
				$list[$k]['name']=stripslashes($v['name']); 
			}
		}

	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '商家列表');
	
		$this->display();
	 }
	
	function editshop(){
        $id = intval($_GET['id']);
		$areas = M('pz_areas')->order('ctime desc,id desc')->select();
	    $this->assign('areas', $areas);
		if($id==''){
		     $this->assign('pagetitle', '添加商家');
		}else{
			 $list = M('shop')->find($id);
				foreach($list as $k=>$v){
					if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
						$list[$k]=stripslashes($v); 
					} 
				}
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改商家');
		}
		
		$lang=M('pz_lang')->where("state=1")->order('xu asc,id asc')->select();
		foreach($lang as $k=>$v){
			$lang[$k]['menu_name']=$list["name".$v['id'].""];
			$lang[$k]['menu_basinf']=$list["basinf".$v['id'].""];
			$lang[$k]['menu_sintro']=$list["sintro".$v['id'].""];
			$lang[$k]['menu_intro']=$list["intro".$v['id'].""];
			$lang[$k]['menu_taoxi']=$list["taoxi".$v['id'].""];
			$lang[$k]['menu_qa']=$list["qa".$v['id'].""];
			$lang[$k]['menu_attention']=$list["attention".$v['id'].""];
		}
	    $this->assign('lang_name', $lang);
	    $this->assign('lang_basinf', $lang);
	    $this->assign('lang_sintro', $lang);
	    $this->assign('lang_intro', $lang);
	    $this->assign('lang_taoxi', $lang);
	    $this->assign('lang_qa', $lang);
	    $this->assign('lang_attention', $lang);

		$this->display('shop_edit');
	}
   
   function doshop(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		
		$_POST['areas_id']=",".$_POST['areas_id'].",";
		if($_POST['id']){
			$pan_admin=$this->pan_quan(2);//判断权限
			$_POST['stime']=time();
			if( M('shop')->save($_POST) ){
				$this->assign('jumpUrl', U('Content/shop'));
				$this->success('修改成功！');
			}else{
				$this->error('没有任何改动　或　修改失败！');
			}
		}else{
			$_POST['uid']=$_SESSION['uid'];
			$pan_admin=$this->pan_quan(4);//判断权限
			$_POST['ctime']=time();
			$_POST['stime']=time();
			if( M('shop')->add($_POST) ){
				$this->assign('jumpUrl', U('Content/shop'));
				$this->success('添加成功！');
			}else{
				$this->error('添加失败！');
			}
		}
	}
	
//	function delshop(){
//	    $ids = $_POST['ids'];
//		$del = M('shop')->where("id IN ($ids)")->setField('state','3');
//        echo $del?'1':'0';
//	}	
  
	/**
	 * ------------------------------
	 * 自动保存 商家
	 * ------------------------------
	 */
	function auto_save_shop(){
	    $id = $_POST['id'];
	    $con = $_POST['con'];
	    $obj = $_POST['obj'];
		$save['id']=$id;
		$save[$obj]=$con;
		
		if($id){
			$save['stime']=time();
			$cc=M('shop')->save($save);
		}else{
			$save['uid']=$_SESSION['uid'];
			$save['ctime']=time();
			$save['stime']=time();
			$cc=M('shop')->add($save);
		}
        echo $cc?$cc:'0';
	}	
	/**
	 * ------------------------------
	 * 商家-top产品图 管理
	 * ------------------------------
	 */
	function shop_topphoto(){
        $aid = intval($_GET['aid']);
		$this->assign('aid',$aid);
		$list = M('shop_topphoto')->where("aid=".$aid."")->order("xu asc,id desc")->select();
		foreach($list as $k=>$v){
			$user=M("admin")->find($v['uid']);
			$list[$k]['username']=$user['adm_name'];
			if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
				$list[$k]['name']=stripslashes($v['name']); 
			}
		}
		$this->assign('list',$list);
		$this->assign('pagetitle', 'top产品');
		$this->display();
	}

	function editshop_topphoto(){
        $id = intval($_GET['id']);
        $aid = intval($_GET['aid']);
		$this->assign('aid',$aid);
		if(!$aid){
			$this->assign('jumpUrl', U('Content/shop'));
			$this->error('数据错误！');
		}
		if($id==''){
			$list_num=M('shop_topphoto')->where("aid=".$aid."")->count();
			if($list_num>=3){
				$this->assign('jumpUrl', U('Content/shop_topphoto',array(aid=>$aid)));
				$this->error('最多只能添加3张图！');
			}
		     $this->assign('pagetitle', '添加top产品');
		}else{
			 $list = M('shop_topphoto')->find($id);
				foreach($list as $k=>$v){
					if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
						$list[$k]=stripslashes($v); 
					} 
				}
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改top产品');
		}
		
		$lang=M('pz_lang')->where("state=1")->order('xu asc,id asc')->select();
		foreach($lang as $k=>$v){
			$lang[$k]['menu_name']=$list["name".$v['id'].""];
			$lang[$k]['menu_url']=$list["url".$v['id'].""];
			$lang[$k]['menu_urlly']=$list["urlly".$v['id'].""];
			$lang[$k]['menu_intro']=$list["intro".$v['id'].""];
		}
	    $this->assign('lang_name', $lang);
	    $this->assign('lang_url', $lang);
	    $this->assign('lang_urlly', $lang);
	    $this->assign('lang_intro', $lang);

		$this->display('shop_topphoto_edit');
	}
   function doshop_topphoto(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
        $aid = intval($_POST['aid']);
		$this->assign('aid',$aid);
		if(!$aid){
			$this->assign('jumpUrl', U('Content/shop'));
			$this->error('数据错误！');
		}
		$_POST['aid']=$aid;
		$_POST['state']=1;
		if($_POST['id']){
			$_POST['stime']=time();
			if( M('shop_topphoto')->save($_POST) ){
				$this->assign('jumpUrl', U('Content/shop_topphoto',array(aid=>$aid)));
				$this->success('修改成功！');
			}else{
				$this->error('没有任何改动　或　修改失败！');
			}
		}else{
			$_POST['uid']=$_SESSION['uid'];
			$_POST['ctime']=time();
			$_POST['stime']=time();
			if( M('shop_topphoto')->add($_POST) ){
				$this->assign('jumpUrl', U('Content/shop_topphoto',array(aid=>$aid)));
				$this->success('添加成功！');
			}else{
				$this->error('添加失败！');
			}
		}
	}
	
//	function delshop_topphoto(){
//	    $ids = $_POST['ids'];
//		$del = M('shop_topphoto')->where("id IN ($ids)")->setField('state','3');
//        echo $del?'1':'0';
//	}	
//	function huishop_topphoto(){
//	    $ids = $_POST['ids'];
//		$del = M('shop_topphoto')->where("id IN ($ids)")->setField('state','1');
//        echo $del?'1':'0';
//	}	
	/**
	 * ------------------------------
	 * 商家-资料 管理
	 * ------------------------------
	 */
	function shop_info(){
        $aid = intval($_GET['aid']);
		$this->assign('aid',$aid);
		$list = M('shop_info')->where("sid=".$aid."")->order("xu asc,ctime desc,id desc")->select();
		foreach($list as $k=>$v){
			$user=M("admin")->find($v['uid']);
			$list[$k]['username']=$user['adm_name'];
			if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
				$list[$k]['name']=stripslashes($v['name']); 
			}
		}
		$this->assign('list',$list);
		$this->assign('pagetitle', '店面资料');
		$this->display();
	}

	function editshop_info(){
        $id = intval($_GET['id']);
        $aid = intval($_GET['aid']);
		$this->assign('aid',$aid);
		if(!$aid){
			$this->assign('jumpUrl', U('Content/shop'));
			$this->error('数据错误！');
		}
		if($id==''){
			$list_num=M('shop_info')->where("sid=".$aid."")->count();
			if($list_num>=999){
				$this->assign('jumpUrl', U('Content/shop_info',array(aid=>$aid)));
				$this->error('最多只能添加999家分店！');
			}
		     $this->assign('pagetitle', '添加店面资料');
		}else{
			 $list = M('shop_info')->find($id);
				foreach($list as $k=>$v){
					if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
						$list[$k]=stripslashes($v); 
					} 
				}
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改店面资料');
		}
		
		$lang=M('pz_lang')->where("state=1")->order('xu asc,id asc')->select();
		foreach($lang as $k=>$v){
			$lang[$k]['menu_name']=$list["name".$v['id'].""];
			$lang[$k]['menu_openday']=$list["openday".$v['id'].""];
			$lang[$k]['menu_opentime']=$list["opentime".$v['id'].""];
			$lang[$k]['menu_address']=$list["address".$v['id'].""];
			$lang[$k]['menu_tel']=$list["tel".$v['id'].""];
			$lang[$k]['menu_fax']=$list["fax".$v['id'].""];
			$lang[$k]['menu_email']=$list["email".$v['id'].""];
		}
	    $this->assign('lang_name', $lang);
	    $this->assign('lang_openday', $lang);
	    $this->assign('lang_opentime', $lang);
	    $this->assign('lang_address', $lang);
	    $this->assign('lang_tel', $lang);
	    $this->assign('lang_fax', $lang);
	    $this->assign('lang_email', $lang);

		$this->display('shop_info_edit');
	}
   function doshop_info(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
        $aid = intval($_POST['aid']);
		$this->assign('aid',$aid);
		if(!$aid){
			$this->assign('jumpUrl', U('Content/shop'));
			$this->error('数据错误！');
		}
		if($_POST['xu']<=0){
			$_POST['xu']=9999;
		}
		$_POST['sid']=$aid;
		$_POST['state']=1;
		
		if($_POST['id']){
			$_POST['stime']=time();
			if( M('shop_info')->save($_POST) ){
				$this->assign('jumpUrl', U('Content/shop_info',array(aid=>$aid)));
				$this->success('修改成功！');
			}else{
				$this->error('没有任何改动　或　修改失败！');
			}
		}else{
			$_POST['uid']=$_SESSION['uid'];
			$_POST['ctime']=time();
			$_POST['stime']=time();
			if( M('shop_info')->add($_POST) ){
				$this->assign('jumpUrl', U('Content/shop_info',array(aid=>$aid)));
				$this->success('添加成功！');
			}else{
				$this->error('添加失败！');
			}
		}
	}
	
//	function delshop_info(){
//	    $ids = $_POST['ids'];
//		$del = M('shop_info')->where("id IN ($ids)")->setField('state','3');
//        echo $del?'1':'0';
//	}	
//	function huishop_info(){
//	    $ids = $_POST['ids'];
//		$del = M('shop_info')->where("id IN ($ids)")->setField('state','1');
//        echo $del?'1':'0';
//	}	
	//保存地图坐标
    function save_shop_info_map() {
        $addx = $_POST['addx'];
        $addy = $_POST['addy'];
        $id = $_POST['id'];
		$add["map_x"]=$addx;
		$add["map_y"]=$addy;
		
		
		if($id){
			$add["id"]=$id;
			$add['stime']=time();
			$shop_info_mapid=M('shop_info')->save($add);
		}else{
			$add['ctime']=time();
			$add['stime']=time();
			$add['uid']=$_SESSION['uid'];
			$shop_info_mapid=M('shop_info')->add($add);
		}
		echo $shop_info_mapid;
    }
	/**
	 * ------------------------------
	 * 自动保存 商家-资料
	 * ------------------------------
	 */
	function auto_save_shop_info(){
	    $id = $_POST['id'];
	    $sid = $_POST['sid'];
	    $con = $_POST['con'];
	    $obj = $_POST['obj'];
		$save['id']=$id;
		$save['sid']=$sid;
		$save[$obj]=$con;
		
		
		if($id){
			$save['stime']=time();
			$cc=M('shop_info')->save($save);
		}else{
			$save['ctime']=time();
			$save['stime']=time();
			$save['uid']=$_SESSION['uid'];
			$cc=M('shop_info')->add($save);
		}
        echo $cc?$cc:'0';
	}	
	
	/**
	 * ------------------------------
	 * 商家-视频 管理
	 * ------------------------------
	 */
	function shop_video(){
        $aid = intval($_GET['aid']);
		$this->assign('aid',$aid);
		$list = M('shop_video')->where("aid=".$aid."")->order("xu asc,id desc")->select();
		foreach($list as $k=>$v){
			$user=M("admin")->find($v['uid']);
			$list[$k]['username']=$user['adm_name'];
			if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
				$list[$k]['name']=stripslashes($v['name']); 
			}
		}
		$this->assign('list',$list);
		$this->assign('pagetitle', '视频');
		$this->display();
	}

	function editshop_video(){
        $id = intval($_GET['id']);
        $aid = intval($_GET['aid']);
		$this->assign('aid',$aid);
		if(!$aid){
			$this->assign('jumpUrl', U('Content/shop'));
			$this->error('数据错误！');
		}
		if($id==''){
			$list_num=M('shop_video')->where("aid=".$aid."")->count();
			if($list_num>=10){
				$this->assign('jumpUrl', U('Content/shop_video',array(aid=>$aid)));
				$this->error('最多只能添加10个视频！');
			}
		     $this->assign('pagetitle', '添加视频');
		}else{
			 $list = M('shop_video')->find($id);
				foreach($list as $k=>$v){
					if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
						$list[$k]=stripslashes($v); 
					} 
				}
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改视频');
		}
		
		$lang=M('pz_lang')->where("state=1")->order('xu asc,id asc')->select();
		foreach($lang as $k=>$v){
			$lang[$k]['menu_name']=$list["name".$v['id'].""];
			$lang[$k]['menu_url']=$list["url".$v['id'].""];
			$lang[$k]['menu_urlly']=$list["urlly".$v['id'].""];
			$lang[$k]['menu_intro']=$list["intro".$v['id'].""];
		}
	    $this->assign('lang_name', $lang);
	    $this->assign('lang_url', $lang);
	    $this->assign('lang_urlly', $lang);
	    $this->assign('lang_intro', $lang);

		$this->display('shop_video_edit');
	}
   function doshop_video(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
        $aid = intval($_POST['aid']);
		$this->assign('aid',$aid);
		if(!$aid){
			$this->assign('jumpUrl', U('Content/shop'));
			$this->error('数据错误！');
		}
		$_POST['aid']=$aid;
		$_POST['state']=1;
		
		if($_POST['id']){
			$_POST['stime']=time();
			if( M('shop_video')->save($_POST) ){
				$this->assign('jumpUrl', U('Content/shop_video',array(aid=>$aid)));
				$this->success('修改成功！');
			}else{
				$this->error('没有任何改动　或　修改失败！');
			}
		}else{
			$_POST['ctime']=time();
			$_POST['stime']=time();
			$_POST['uid']=$_SESSION['uid'];
			if( M('shop_video')->add($_POST) ){
				$this->assign('jumpUrl', U('Content/shop_video',array(aid=>$aid)));
				$this->success('添加成功！');
			}else{
				$this->error('添加失败！');
			}
		}
	}
	
	function delshop_video(){
	    $ids = $_POST['ids'];
		$del = M('shop_video')->where("id IN ($ids)")->setField('state','3');
        echo $del?'1':'0';
	}	

	/**
	 * ------------------------------
	 * 商家-相片集 管理
	 * ------------------------------
	 */
	function shop_photo_files(){
        $aid = intval($_GET['aid']);
		$this->assign('aid',$aid);
		$list = M('shop_photo_files')->where("aid=".$aid."")->order("xu asc,id desc")->select();
		foreach($list as $k=>$v){
			$user=M("admin")->find($v['uid']);
			$list[$k]['username']=$user['adm_name'];
			if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
				$list[$k]['name']=stripslashes($v['name']); 
			}
		}
		$this->assign('list',$list);
		$this->assign('pagetitle', '相片集');
		$this->display();
	}

	function editshop_photo_files(){
        $id = intval($_GET['id']);
        $aid = intval($_GET['aid']);
		$this->assign('aid',$aid);
		if(!$aid){
			$this->assign('jumpUrl', U('Content/shop'));
			$this->error('数据错误！');
		}
		if($id==''){
			$list_num=M('shop_photo_files')->where("aid=".$aid."")->count();
			if($list_num>=20){
				$this->assign('jumpUrl', U('Content/shop_photo_files',array(aid=>$aid)));
				$this->error('最多只能添加20个相册！');
			}
		     $this->assign('pagetitle', '添加相片集');
		}else{
			 $list = M('shop_photo_files')->find($id);
				foreach($list as $k=>$v){
					if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
						$list[$k]=stripslashes($v); 
					} 
				}
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改相片集');
		}
		
		$lang=M('pz_lang')->where("state=1")->order('xu asc,id asc')->select();
		foreach($lang as $k=>$v){
			$lang[$k]['menu_name']=$list["name".$v['id'].""];
			$lang[$k]['menu_url']=$list["url".$v['id'].""];
			$lang[$k]['menu_urlly']=$list["urlly".$v['id'].""];
			$lang[$k]['menu_intro']=$list["intro".$v['id'].""];
		}
	    $this->assign('lang_name', $lang);
	    $this->assign('lang_url', $lang);
	    $this->assign('lang_urlly', $lang);
	    $this->assign('lang_intro', $lang);

		$this->display('shop_photo_files_edit');
	}
   function doshop_photo_files(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
        $aid = intval($_POST['aid']);
		$this->assign('aid',$aid);
		if(!$aid){
			$this->assign('jumpUrl', U('Content/shop'));
			$this->error('数据错误！');
		}
		$_POST['aid']=$aid;
		$_POST['state']=1;
		
		if($_POST['id']){
			$_POST['stime']=time();
			if( M('shop_photo_files')->save($_POST) ){
				$this->assign('jumpUrl', U('Content/shop_photo_files',array(aid=>$aid)));
				$this->success('修改成功！');
			}else{
				$this->error('没有任何改动　或　修改失败！');
			}
		}else{
			$_POST['ctime']=time();
			$_POST['stime']=time();
			$_POST['uid']=$_SESSION['uid'];
			if( M('shop_photo_files')->add($_POST) ){
				$this->assign('jumpUrl', U('Content/shop_photo_files',array(aid=>$aid)));
				$this->success('添加成功！');
			}else{
				$this->error('添加失败！');
			}
		}
	}
	
	function delshop_photo_files(){
	    $ids = $_POST['ids'];
		$del = M('shop_photo_files')->where("id IN ($ids)")->setField('state','3');
        echo $del?'1':'0';
	}	

	/**
	 * ------------------------------
	 * 商家-相片管理
	 * ------------------------------
	 */
	function shop_photo(){
        $fid = intval($_GET['fid']);
		$this->assign('fid',$fid);
		$photo_files=M('shop_photo_files')->find($fid);
		$aid=$photo_files['aid'];
		$this->assign('aid',$aid);
		$list = M('shop_photo')->where("fid=".$fid."")->order("xu asc,id desc")->select();
		foreach($list as $k=>$v){
			$user=M("admin")->find($v['uid']);
			$list[$k]['username']=$user['adm_name'];
			if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
				$list[$k]['name']=stripslashes($v['name']); 
			}
		}
		$this->assign('list',$list);
		$this->assign('pagetitle', '相片');
		$this->display();
	}

	function editshop_photo(){
        $id = intval($_GET['id']);
        $fid = intval($_GET['fid']);
		$this->assign('fid',$fid);
		if(!$fid){
			$this->assign('jumpUrl', U('Content/shop'));
			$this->error('数据错误！');
		}
		if($id==''){
			$list_num=M('shop_photo')->where("fid=".$fid."")->count();
			if($list_num>=20){
				$this->assign('jumpUrl', U('Content/shop_photo',array(fid=>$fid)));
				$this->error('最多只能添加20张相片！');
			}
		     $this->assign('pagetitle', '添加相片');
		}else{
			 $list = M('shop_photo')->find($id);
				foreach($list as $k=>$v){
					if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
						$list[$k]=stripslashes($v); 
					} 
				}
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改相片');
		}
		
		$lang=M('pz_lang')->where("state=1")->order('xu asc,id asc')->select();
		foreach($lang as $k=>$v){
			$lang[$k]['menu_name']=$list["name".$v['id'].""];
			$lang[$k]['menu_url']=$list["url".$v['id'].""];
			$lang[$k]['menu_urlly']=$list["urlly".$v['id'].""];
		}
	    $this->assign('lang_name', $lang);
	    $this->assign('lang_url', $lang);
	    $this->assign('lang_urlly', $lang);

		$this->display('shop_photo_edit');
	}
   function doshop_photo(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
        $fid = intval($_POST['fid']);
		$this->assign('fid',$fid);
		if(!$fid){
			$this->assign('jumpUrl', U('Content/shop'));
			$this->error('数据错误！');
		}
		$_POST['fid']=$fid;
		$_POST['state']=1;
		
		if($_POST['id']){
			$_POST['stime']=time();
			if( M('shop_photo')->save($_POST) ){
				$this->assign('jumpUrl', U('Content/shop_photo',array(fid=>$fid)));
				$this->success('修改成功！');
			}else{
				$this->error('没有任何改动　或　修改失败！');
			}
		}else{
			$_POST['ctime']=time();
			$_POST['stime']=time();
			$_POST['uid']=$_SESSION['uid'];
			if( M('shop_photo')->add($_POST) ){
				$this->assign('jumpUrl', U('Content/shop_photo',array(fid=>$fid)));
				$this->success('添加成功！');
			}else{
				$this->error('添加失败！');
			}
		}
	}
	
	function delshop_photo(){
	    $ids = $_POST['ids'];
		$del = M('shop_photo')->where("id IN ($ids)")->setField('state','3');
        echo $del?'1':'0';
	}	


	/**
	 * ------------------------------
	 * 用户管理
	 * ------------------------------
	 */
	function user(){
	
		import("@.ORG.Page");
		$count	= M('user')->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('user')->order('ctime desc,id desc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();
							 
		foreach($list as $k=>$v){
			$user=M("admin")->find($v['uid']);
			$list[$k]['username']=$user['adm_name'];
			if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
				$list[$k]['name']=stripslashes($v['name']); 
			}
		}

	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '用户信息列表');
	
		$this->display();
	 }
	
	function edituser(){
        $id = intval($_GET['id']);
		$list1 = M('daren')->select();
	    $this->assign('list1', $list1);
		
		
		if($id==''){
		     $this->assign('pagetitle', '添加用户信息');
		}else{
			 $list = M('user')->find($id);
				foreach($list as $k=>$v){
					if(get_magic_quotes_gpc()!='-1' || get_magic_quotes_gpc()==true){
						$list[$k]=stripslashes($v); 
					} 
				}
              if($list['xingbie']==0){
				  $list['xingbie']="男";  
			  }else{
				  $list['xingbie']="女"; 
			  }
			 $this->assign($list);
			 $this->assign('type', 'edit');
			 $this->assign('pagetitle', '修改用户信息');
		}
		$this->display('user_edit');
	}
   
   function douser(){
	   
   	    header("Content-Type:text/html; charset=utf-8");
		if( !M()->autoCheckToken($_POST) ) $this->error('禁止站外提交！');
		unset($_POST['__hash__']);
		foreach ($_POST as $k => $v) {
			if($v == '') unset($_POST[$k]);
		}
		
		
		if($_POST['id']){
			
				if(!$_POST['getuijian']){
					$_POST['getuijian']="0";
					$_POST['gtime']="0";	
				}else{
					$_POST['gtime']=time();	
				}
				if(!$_POST['shoutuijian']){
					$_POST['shoutuijian']="0";	
					$_POST['stime']="0";
				}else{
					$_POST['stime']=time();	
				}

				
				if( M('user')->save($_POST) ){
					$this->assign('jumpUrl', U('Content/user'));
					$this->success('修改成功！');
				}else{
					$this->error('没有任何改动　或　修改失败！');
				}
		}else{
		      if( M('user')->add($_POST) ){
					$this->assign('jumpUrl', U('Content/user'));
					$this->success('添加成功！');
			  }else{
					$this->error('添加失败！');
			  }
		}
	}
	
	function deluser(){
	    $ids = $_POST['ids'];
		$del = M('user')->where("id IN ($ids)")->setField('state','3');
        echo $del?'1':'0';
	}	
    /**
	 * ------------------------------
	 * 搜索用户昵称
	 * ------------------------------
	 */
	function searchuser(){
		 $name=$_REQUEST['name'];
		 $this->assign('name',$name);	 	
		import("@.ORG.Page");
		$count	= M('user')->where("nicheng like '%$name%'")->count();
		$Page	= New Page($count,15);
		$show	= $Page->show();
		$list = M('user')->where("nicheng like '%$name%'")->order('ctime desc,id desc')->limit($Page->firstRow.','.$Page->listRows)
						     ->select();

		
	    $this->assign('list', $list);
		$this->assign('page', $show);
		$this->assign('pagetitle', '搜索用户信息列表');
	
		$this->display('user');
	 }	  


 
	
}
?>